from blockchain_main import Blockchain
from socket_main import SocketIO
from modules.entities.chain import Block
from modules.entities.node import Node

if __name__ == '__main__':
    b1 = Blockchain()
    # b2 = Blockchain()
    ip, port = input("请输入区块链绑定的IP地址和端口\n").split()
    s1 = SocketIO(b1, ip, int(port))
    id = input("请输入区块链所在的节点ID\n")
    s1.blockchain.node_id = id
    while True:
        id, ip, port = input("请输入邻居节点的id、ip、port, 输入q,q,q退出\n").split()
        # s2 = SocketIO(b2, "127.0.0.1", 8081)
        if id == ip == port == "q":
            break
        s1.blockchain.nodes.append(Node(id, (ip, int(port))))
    s1.run()
    # s2.run()
